package ups.MapParse;

public class Pixel {
	short r, g, b, a;
	int intValue;
	
	public static Pixel redPixel = new Pixel(-65536);
	public static Pixel whitePixel = new Pixel(0);
	public static Pixel bluePixel = new Pixel(-16776961);
	public static Pixel yellowPixel = new Pixel(-1776961);
	public static Pixel greenPixel = new Pixel( 65280 );
	
	public Pixel( int pixel )
	{
		// Ugly, but works. Tested only on Intel.
		intValue = pixel;
	 	a = (short)(0x000000FF & (byte)((pixel >>> 24) & 0xFF));
		r = (short)(0x000000FF & (byte)((pixel >>> 16) & 0xFF));
		g = (short)(0x000000FF & (byte)((pixel >>> 8) & 0xFF));
		b = (short)(0x000000FF & (byte)((pixel >>> 0) & 0xFF));
	}
	
	public short getRed() { return r; }
	public short getGreen() { return g; }
	public short getBlue() { return b; }
	public short getAlpha() { return a; }
	public int 	 getIntValue() { return intValue; }
	
	public boolean equals(Pixel p) { return p.getIntValue() == this.getIntValue(); }
	
	public String toString() { 
		switch( intValue ) {
		case -65536:
			return "RED";
		case -16776961:
			return "BLUE";
		default:
		return (r + " " + g + " " + b + " " + a); }
	}
}
